from paddlespeech.cli.asr.infer import ASRExecutor
asr = ASRExecutor()

audio_paths = "test.wav"

result = asr(audio_file=audio_paths, lang="zh")
print(result)


# import speech_recognition as sr
# r = sr.Recognizer()    #调用识别器
# import librosa
# import soundfile as sf

# def resample_wav(input_path, output_path, target_sample_rate=16000):
#     y, sr = librosa.load(input_path, sr=None)  # 加载音频文件，保持原采样率
#     y_resampled = librosa.resample(y, orig_sr=sr, target_sr=target_sample_rate)
#     sf.write(output_path, y_resampled, target_sample_rate)

# input_wav = 'test.wav'
# output_wav = 'jesus2.wav'
# resample_wav(input_wav, output_wav)


# test = sr.AudioFile(output_wav)   #导入语音文件

# with test as source:       
#     audio = r.record(source)
# type(audio)
# c=r.recognize_sphinx(audio, language='zh-cn')     #识别输出
# print(c)